package cn.edu.scau.cmi.dengshixin.composite.consistent;

import java.util.ArrayList;

public class OrganizationConsistentComposite extends OrganizationConsistentComponent {
	
	private ArrayList<OrganizationConsistentComponent> children = new ArrayList<OrganizationConsistentComponent>();
	
	public OrganizationConsistentComposite(String name) {
		this.name = name;
		this.organization = null;
	}
	
	public OrganizationConsistentComposite(String name, String organization) {
		this.name = name;
		this.organization = organization;
	}
	
	public void doSomething() {
		if(name != null) {
			System.out.print("我们是[" + this.name + "]部门！");
			if(this.organization != null) {
				System.out.println("隶属于[" + this.organization + "]部门！");
			}
			else {
				System.out.println();
			}
		}
		for(OrganizationConsistentComponent child : children) {
			child.doSomething();
		}
	}
	
	public boolean addChild(OrganizationConsistentComponent oc) {
		return children.add(oc);
	}
	
	public boolean removeChild(OrganizationConsistentComponent oc) {
		return children.remove(oc);
	}
	
	public ArrayList<OrganizationConsistentComponent> getChildren() {
		return children;
	}

	public void setChildren(ArrayList<OrganizationConsistentComponent> children) {
		this.children = children;
	}
	
}
